package com.baoyouqun.domain.VO;

import cn.hutool.core.collection.CollUtil;
import com.baoyouqun.domain.Enum.DemandTypeEnum;
import com.baoyouqun.domain.Enum.PhonePrivacyEnum;
import com.baoyouqun.domain.Enum.ResourceUrgencyEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class DemandVO implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键ID")
    private String id;

    @ApiModelProperty(value = "发布用户ID")
    private String userId;

    @ApiModelProperty(value = "发布类型")
    private DemandTypeEnum type;

    @ApiModelProperty(value = "展示地区code")
    private String cityCode;

    @ApiModelProperty(value = "展示地区名称")
    private String cityName;

    @ApiModelProperty(value = "标签")
    private String tag;

    @ApiModelProperty(value = "行业")
    private String industry;

    @ApiModelProperty(value = "需求标题")
    private String title;

    @ApiModelProperty(value = "需求描述")
    private String description;


    @ApiModelProperty(value = "附件")
    private List<String> fileList;

    @ApiModelProperty(value = "手机号隐私保护*")
    private PhonePrivacyEnum phonePrivacy;

    @ApiModelProperty(value = "资源紧急程度")
    private ResourceUrgencyEnum resourceUrgency;

    @ApiModelProperty(value = "是否长期有效")
    private Boolean neverExpire;

    @ApiModelProperty(value = "过期时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expireTime;

    @ApiModelProperty(value = "浏览量")
    private Integer viewCount;

    @ApiModelProperty(value = "点赞数")
    private Integer likeCount;

    @ApiModelProperty(value = "踩数")
    private Integer dislikeCount;

    @ApiModelProperty(value = "收藏数")
    private Integer collectCount;

    @ApiModelProperty(value = "状态（0-隐藏，1-正常，2-删除 ,-1下架）")
    private Byte status;

    @ApiModelProperty(value = "发布时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "刷新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime refreshTime;

    @ApiModelProperty(value = "发布人基本信息")
    private UserSimpleVO userSimpleVO;

    @ApiModelProperty(value = "当前用户是否点赞")
    private Boolean isLiked; // true:已点赞, false:未点赞

    @ApiModelProperty(value = "当前用户是否点踩")
    private Boolean isDisliked; // true:已点踩, false:未点踩

    @ApiModelProperty(value = "当前用户是否收藏")
    private Boolean collect;

    private List<String> viewUserIds;

    public Integer getViewCount() {
        if (CollUtil.isEmpty(viewUserIds)) {
            return viewCount = 0;
        } else {
            viewCount = viewUserIds.size();
        }
        return viewCount;
    }
}